﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseSet.Data;
using BaseSet.Logic;
using BaseSet.Entity;
using BaseSet.Framework;
using BaseSet.Entity.Common;
using BaseSet.Entity.Common.Text;
using BaseSet;
using System.Data;


namespace WebSite.Blogs
{
    public partial class RecommandUser : PreBasePage
    {
        private string blogid = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            blogid = Request.QueryString["id"] + "";
            if (!Page.IsPostBack)
            {
                LoadContent();
                LoadRecommandList();
            }
        }

        #region 加载博客内容
        private void LoadContent()
        {
            Blog binfo = new Blog();
            BlogHelper bhelper = new BlogHelper();

            binfo = bhelper.GetBlog(blogid);
            litBlogName.Text = binfo.Title;
        }
        #endregion

        #region 加载博客推荐列表
        private void LoadRecommandList()
        {
            //设置控件属性，从BasePage中得到
            PageConfig(RecommandUPager);

            RecommandHelper rhelper = new RecommandHelper();
            Criteria c = new Criteria();
            c.Add(CriteriaType.Equals, "ObjectID", blogid);
            c.Add(CriteriaType.Equals, "ObjectType", 1);

            RecommandUPager.ItemCount = rhelper.QueryRecommandCountBySearch(c);

            // 以下的值从BasePage中得到
            RecommandUPager.UrlFormat = UrlFormat;
            //RecommandUPager.PrefixText = GetPreFixText(RecommandUPager);

            DataTable dt = rhelper.QueryRecommandBySearchToTable(c, new Order[] { new Order("CreateDate", OrderMode.Desc) }, RecommandUPager.Begin - 1, RecommandUPager.Count, null);

            rptRecommandList.DataSource = dt;
            rptRecommandList.DataBind();
        }
        #endregion
    }
}